import 'package:flutter/material.dart';
import '../demo/ui_demo.dart';
import '../demo/data_source/post.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});


  @override
  Widget build(BuildContext context) {
    return  Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("Steper","14"),
        ],
      ),
      body: Theme(data: Theme.of(context).copyWith(
        primaryColor: Colors.black
      ),
          child: SteperDemo()
      ),
    );
  }
}
class SteperDemo extends StatefulWidget {
  @override
  _SteperDemoState createState() => _SteperDemoState();
}

class _SteperDemoState extends State<SteperDemo> {
  int _isAction=0;
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(8.0),
      child: Stepper(
        currentStep: _isAction,
        onStepTapped: (int value){
          setState(() {
            _isAction=value;
          });
        },
        onStepContinue: (){
         setState(() {
           _isAction>=2?_isAction=2:_isAction+=1;
         });
        },
        onStepCancel: (){
          setState(() {
            _isAction>0?_isAction-=1:_isAction=0;
          });
        },
        steps: <Step>[
          Step(
            title: Text("第一步"),
            subtitle: Text("把冰箱门打开"),
            content: Text("找个大点的冰箱，断电，打开冰箱门"),
            isActive: _isAction==0,
          ),
          Step(
            title: Text("第二步"),
            subtitle: Text("把大象装进去"),
            content: Text("找个小点的大象，塞进冰箱"),
            isActive: _isAction==1,
          ),
          Step(
            title: Text("第三步"),
            subtitle: Text("把冰箱门关上"),
            content: Text("视情况而定，如果确实关不上，就开着吧"),
            isActive: _isAction==2,
          ),
        ],
      ),
    );
  }
}


